package com.sell.handler;

import com.sell.exception.SellerAuthorizeException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.servlet.ModelAndView;

/**
 * Created by caiqibin on 18/3/24.
 */
@ControllerAdvice
public class SellExceptionHandler {

    //拦截登陆异常
    @ExceptionHandler(value = SellerAuthorizeException.class)
    @ResponseStatus(HttpStatus.FORBIDDEN)
    public ModelAndView handlerAuthorizeException(){
        return new ModelAndView("redirect:"
                .concat("http://127.0.0.1:8080")
                .concat("/sell/wechat/qrAuthorize")
                .concat("?returnUrl?")
                .concat("http://127.0.0.1:8080")
                .concat("/sell/seller/login")
        );
    }

}
